package com.jmodusoperandi.orders.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="ord_orders", schema="orders")
public class Order {
	
	@Id
	@Column(name="ord_orders_id")
	private String id;

	@Temporal(value=TemporalType.DATE)
	@Column(name="ord_orders_date")
	private Date date;
	
	@ManyToOne
	@JoinColumn(name="ord_orders_client_id", referencedColumnName="cli_clients_id")
	private Client client;

	public Order() {
		super();
	}

	public Order(String id, Date date, Client client) {
		super();
		this.id = id;
		this.date = date;
		this.client = client;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Order other = (Order) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}
	
	
}
